<!--
 * @Description: 无需结算商品列表
 * @Author: liyujie
 * @Date: 2021/7/7
 * @Last Modified by: liyujie
 * @Last Modified time: 2021/7/7
-->
<template>
    <section class="wrapper">
        <div class="content-wrapper">
            <!-- header -->
            <div class="header">
                <div class="header-title">
                    无需结算商品列表
                </div>
                <div
                    class="back"
                    @click="handleRoute('GoodsList')"
                >返回</div>
            </div>
            <!-- /header -->
            <div class="tips-view">
                以下商品为体验精英账号商品，所产生佣金无需结算直接到账，谨慎添加！
            </div>
            <!-- 筛选-->
            <div class="filter-view">
                <div class="left">
                    <div class="header-new-box">
                        <p class="header-new-box-title">
                            商品分类
                        </p>
                        <el-cascader
                            placeholder="请选择"
                            :options="typeList"
                            filterable
                            clearable
                            size="medium"
                            change-on-select
                            expand-trigger="click"
                            v-model="filterData.selectedType"
                            @change="getTableData(1)"
                            :props="{
                                label: 'title',
                                value: 'no',
                                children: 'children'
                            }"
                        />
                    </div>
                    <div class="header-new-box">
                        <p class="header-new-box-title">
                            商品名称
                        </p>
                        <el-input
                            v-model="filterData.goods_title"
                            size="medium"
                            clearable
                            placeholder="请输入商品名称"
                            @keyup.native.enter="getTableData(1)"
                        />
                    </div>
                    <div class="header-new-box">
                        <el-button
                            type="primary"
                            size="small"
                            class="query-button"
                            @click="getTableData(1)"
                        >
                            查询
                        </el-button>
                        <el-button
                            type="text"
                            @click="handleReset()"
                        >
                            重置
                        </el-button>
                    </div>
                </div>
                <div class="right">
                    <el-button
                        type="primary"
                        size="medium"
                        icon="el-icon-plus"
                        @click="handleAdd"
                    >添加商品</el-button>
                </div>
            </div>
            <!--筛选-->
            <!-- table -->
            <div class="table-wrapper">
                <el-table
                    :data="tableData"
                    height="100%"
                    style="width: 100%;"
                    class="data-table"
                    :cell-style="{height: '40px'}"
                    v-loading="tableLoading"
                    ref="goodsTable"
                    @select="fnSelect"
                    @select-all="fnSelectAllTop"
                    @selection-change="handleSelectionChange"
                    @sort-change="handleSortChanged"
                >
                    <el-table-column
                        label="序号"
                        align="center"
                        width="50"
                        type="selection"
                        fixed="left"
                    />
                    <el-table-column
                        width="320"
                        label="商品信息"
                        fixed="left"
                    >
                        <template slot-scope="scope">
                            <div class="goods-info">
                                <img
                                    :src="scope.row.goods_cover"
                                    class="goods-cover"
                                    @click="fnShowPreview(scope.row.goods_cover)"
                                >
                                <div class="info">
                                    <div
                                        class="goods-info__title shop-item-jump"
                                        @click="fnGoShoplist(scope.row)"
                                    >
                                        {{ scope.row.goods_title }}
                                    </div>
                                    <div class="goods-info__no">
                                        商品编号：{{ scope.row.goods_no }}
                                    </div>
                                    <div class="goods-info__shop-title">
                                        店铺名称：{{ scope.row.shop_title }}
                                    </div>
                                </div>
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column
                        label="商品单价"
                        :formatter="emptyFormatter"
                        prop="goods_price"
                        width="110"
                        align="center"
                        sortable="custom"
                    >
                        <template slot-scope="scope">
                            <span v-if="Number(filterData.goods_type) !== 4 ">{{ scope.row.goods_price }}</span>
                            <span v-if="Number(filterData.goods_type) == 4 ">0</span>
                        </template>
                    </el-table-column>
                    <el-table-column
                        :formatter="emptyFormatter"
                        prop="goods_price_origin"
                        width="130"
                        label="淘宝售价"
                        align="center"
                        sortable="custom"
                        :render-header="(h, title, content) => renderHeader(h, '淘宝售价', '淘宝售价为当前该商品在淘宝上的在售价格')"
                    />
                    <el-table-column
                        :formatter="emptyFormatter"
                        prop="goods_commission"
                        label="佣金"
                        sortable="custom"
                    />
                    <el-table-column
                        prop="reduction_info"
                        :formatter="emptyFormatter"
                        label="优惠力度"
                    >
                        <template slot-scope="scope">
                            <div class="cursor-font">
                                <el-popover
                                    placement="left"
                                    :width="scope.row.reduction_info.list.length == 0 ? 120 :'auto'"
                                >
                                    <div
                                        v-if="scope.row.reduction_info.list.length > 0"
                                        :style="{width: '100%', textAlign: 'center', display: 'flex', flexDirection: 'column'}"
                                    >
                                        <div :style="{height: '28px', display: scope.row.reduction_info.list.length > 1 ? 'flex' : '', alignItems: 'center'}">
                                            <div
                                                v-for="(item, index) in scope.row.reduction_info.list"
                                                :key="index"
                                            >
                                                <div
                                                    v-if="index <= 2"
                                                    class="reduction_price"
                                                    :style="{color: scope.row.reduction_info.reduction_type == 2 ? '#FF3030' : '#FDA623', borderColor: scope.row.reduction_info.reduction_type == 2 ? '#FF3030' : '#FDA623', margin: index == 1 ? (scope.row.reduction_info.list.length == 2 ? '0 0 0 12px' : '12px') : '0'}"
                                                >
                                                    满{{ item.require_num }}{{ scope.row.reduction_info.reduction_type == 2 ? '' : '件' }}减{{ item.reduction_price }}
                                                </div>
                                            </div>
                                        </div>
                                        <div
                                            :style="{height: '28px', display: 'flex', alignItems: 'center', marginTop: '18px'}"
                                            v-if="scope.row.reduction_info.list.length > 3"
                                        >
                                            <div
                                                v-for="(item, index) in scope.row.reduction_info.list"
                                                :key="index"
                                            >
                                                <div
                                                    v-if="index > 2"
                                                    class="reduction_price"
                                                    :style="{color: scope.row.reduction_info.reduction_type == 2 ? '#FF3030' : '#FDA623', borderColor: scope.row.reduction_info.reduction_type == 2 ? '#FF3030' : '#FDA623', margin: index == 4 ? (scope.row.reduction_info.list.length == 5 ? '0 0 0 12px' : '12px') : '0'}"
                                                >
                                                    满{{ item.require_num }}{{ scope.row.reduction_info.reduction_type == 2 ? '' : '件' }}减{{ item.reduction_price }}
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div
                                        v-else
                                        :style="{width: '100%', textAlign: 'center'}"
                                    >
                                        暂无数据
                                    </div>
                                    <el-button
                                        slot="reference"
                                        type="text"
                                    >
                                        查看
                                    </el-button>
                                </el-popover>
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column
                        prop="goods_commission_rate"
                        width="110"
                        label="佣金比例"
                    >
                        <template slot-scope="scope">
                            <div class="comp">
                                <template v-if="scope.row.goods_type == 2">
                                    {{ scope.row.goods_commission_rate | commissionRateFilter }}
                                </template>
                                <template v-else>
                                    <el-popover
                                        placement="bottom"
                                        trigger="click">
                                        <div
                                            class="spec-list"
                                            v-if="scope.row.specList">
                                            <div
                                                class="spec-line"
                                                v-for="(specItem, specIndex) in scope.row.specList"
                                                :key="specIndex">
                                                {{ specItem | specFilter }}
                                            </div>
                                        </div>
                                        <el-button
                                            slot="reference"
                                            type="text"
                                            @mouseover.native="fnGetSpec(scope.row)">查看</el-button>
                                    </el-popover>
                                </template>
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column
                        :formatter="emptyFormatter"
                        prop="coupon_money"
                        width="110"
                        label="优惠券"
                        sortable="custom"
                    >
                        <template slot-scope="scope">
                            <span v-if="Number(filterData.goods_type) !== 4 ">{{ scope.row.coupon_money }}</span>
                            <span v-if="Number(filterData.goods_type) == 4 ">0</span>
                        </template>
                    </el-table-column>
                    <el-table-column
                        :formatter="emptyFormatter"
                        prop="goods_freight"
                        width="110"
                        label="运费设置"
                        sortable="custom"
                    >
                        <template slot-scope="scope">
                            <span v-if="Number(filterData.goods_type) !== 4 ">{{ scope.row.goods_freight }}</span>
                            <span v-if="Number(filterData.goods_type) == 4 ">0</span>
                        </template>
                    </el-table-column>
                    <el-table-column
                        prop="goods_type"
                        show-overflow-tooltip
                        width="110"
                        label="商品种类"
                    >
                        <template slot-scope="scope">
                            <span>{{ scope.row.goods_type | setGoodsType }}</span>
                        </template>
                    </el-table-column>
                    <el-table-column
                        prop="type_name"
                        width="110"
                        label="商品分类"
                    />
                    <el-table-column
                        prop="sub_type_name"
                        width="110"
                        label="二级分类"
                    >
                        <template slot-scope="scope">
                            <span>{{ scope.row.sub_type_name }}</span>
                        </template>
                    </el-table-column>
                    <el-table-column
                        prop="agent_cate_name"
                        label="所属代理类目"
                        :width="150"
                        show-overflow-tooltip
                        :formatter="emptyFormatter"
                    >
                        <template slot-scope="scope">
                            {{ scope.row.agent_cate_name ? scope.row.agent_cate_name : '--' }}
                        </template>
                    </el-table-column>
                    <el-table-column
                        prop="school_filter_status"
                        label="是否设置学校权限"
                        show-overflow-tooltip
                        :width="150"
                        align="center"
                        :formatter="emptyFormatter"
                    >
                        <template slot-scope="scope">
                            <p v-if="scope.row.school_filter_status == 1">是</p>
                            <p v-if="scope.row.school_filter_status == 0">否</p>
                        </template>
                    </el-table-column>
                    <el-table-column
                        sortable="custom"
                        prop="goods_sort"
                        label="排序"
                    >
                        <template slot-scope="scope">
                            {{ scope.row.goods_sort }}
                        </template>
                    </el-table-column>
                    <el-table-column
                        sortable="custom"
                        prop="goods_sale"
                        label="真实销量"
                        width="110"
                    />
                    <el-table-column
                        sortable="custom"
                        prop="goods_sale_base"
                        width="110"
                        label="商品销量"
                    >
                        <template slot-scope="scope">
                            {{ scope.row.goods_sale_base }}
                        </template>
                    </el-table-column>
                    <el-table-column
                        header-align="left"
                        prop="autoinc_sale"
                        align="center"
                        width="120"
                        label="是否销量自增长"
                        show-overflow-tooltip
                    >
                        <template slot-scope="scope">
                            <p
                                v-if="scope.row.goods_type == 1 || scope.row.goods_type == 4"
                            >
                                <span v-if="scope.row.autoinc_sale.autoinc_no == ''">
                                    否
                                </span>
                                <span v-if="scope.row.autoinc_sale.autoinc_no !== ''">
                                    是（{{ scope.row.autoinc_sale.inc_count_min ? scope.row.autoinc_sale.inc_count_min * 24 : 0 }} - {{ scope.row.autoinc_sale.inc_count_max ? scope.row.autoinc_sale.inc_count_max * 24 : 0 }} 个/天）
                                </span>
                            </p>
                            <p v-else>--</p>
                        </template>
                    </el-table-column>
                    <el-table-column
                        :formatter="emptyFormatter"
                        prop="goods_view"
                        width="110"
                        label="商品浏览量"
                    />
                    <el-table-column
                        header-align="left"
                        prop="autoinc_view"
                        align="center"
                        width="200"
                        label="是否浏览量自增长"
                        show-overflow-tooltip
                    >
                        <template slot-scope="scope">
                            <p
                                v-if="scope.row.goods_type == 1 || scope.row.goods_type == 4"
                            >
                                <span v-if="scope.row.autoinc_view.autoinc_no == ''">
                                    否
                                </span>
                                <span v-if="scope.row.autoinc_view.autoinc_no !== ''">
                                    是（{{ scope.row.autoinc_view.inc_count_min ? scope.row.autoinc_view.inc_count_min * 24 : 0 }} - {{ scope.row.autoinc_view.inc_count_max ? scope.row.autoinc_view.inc_count_max * 24 : 0 }} 个/天）
                                </span>
                            </p>
                            <p v-else>--</p>
                        </template>
                    </el-table-column>
                    <el-table-column
                        prop="create_time"
                        width="140"
                        label="创建时间"
                        sortable="custom"
                    >
                        <template slot-scope="scope">
                            <template v-if="scope.row.create_time">{{ scope.row.create_time*1000 | dateFormatter('yyyy/MM/dd HH:mm') }}</template>
                            <template v-else>--</template>
                        </template>
                    </el-table-column>
                    <el-table-column
                        prop="shelf_time"
                        width="140"
                        label="上架时间"
                    >
                        <template slot-scope="scope">
                            <template v-if="scope.row.shelf_time">{{ scope.row.shelf_time*1000 | dateFormatter('yyyy/MM/dd HH:mm') }}</template>
                            <template v-else>--</template>
                        </template>
                    </el-table-column>
                    <el-table-column
                        prop="expire_time"
                        width="140"
                        label="下架时间"
                    >
                        <template slot-scope="scope">
                            <template v-if="scope.row.expire_time">{{ scope.row.expire_time*1000 | dateFormatter('yyyy/MM/dd HH:mm') }}</template>
                            <template v-else>--</template>
                        </template>
                    </el-table-column>
                    <el-table-column
                        :formatter="emptyFormatter"
                        prop="hire_settle_status"
                        width="110"
                        label="是否入驻商城"
                    >
                        <template slot-scope="scope">
                            <span v-if="scope.row.hire_settle_status == 1">已入驻</span>
                            <span
                                v-if="scope.row.hire_settle_status == 0"
                                style="color: #F95B56"
                            >
                                未入驻
                            </span>
                        </template>
                    </el-table-column>
                    <el-table-column
                        prop="audit_status"
                        width="100"
                        label="审核状态"
                    >
                        <template slot-scope="scope">
                            <div class="task-review-status">
                                <template v-if="scope.row.audit_status == -1">
                                    <span class="status deny">审核不通过</span>
                                </template>
                                <template v-if="scope.row.audit_status == 0">
                                    <span class="status wait-submit">待审核</span>
                                </template>
                                <template v-if="scope.row.audit_status == 1">
                                    <span class="status completed">审核通过</span>
                                </template>
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column
                        prop="goods_status"
                        width="100"
                        label="上架状态"
                    >
                        <template slot-scope="scope">
                            <div style="color: #999">{{ scope.row.goods_status ? '已上架' : '未上架' }}</div>
                            <el-switch
                                v-model="scope.row.goods_status"
                                :disabled="scope.row.audit_status != 1"
                                :active-value="1"
                                :inactive-value="0"
                                @change="fnSetStatus(scope.row)"/>
                        </template>
                    </el-table-column>
                    <el-table-column
                        label="操作"
                        align="center"
                        fixed="right"
                        width="120"
                    >
                        <template slot-scope="scope">
                            <div class="option-btn-group">
                                <el-button
                                    type="text"
                                    size="medium"
                                    style="color: rgb(249, 91, 86)"
                                    @click="handleDelete([scope.row])"
                                >
                                    移除
                                </el-button>
                            </div>
                        </template>
                    </el-table-column>
                </el-table>
            </div>
            <!-- /table -->
            <!-- /分页 -->
            <div class="pagination-wrapper clearfix">
                <div class="op-view">
                    <el-checkbox
                        label="当页全选"
                        v-model="checkedAll"
                        :indeterminate="checkIndeterminate"
                        :disabled="tableData.length === 0"
                        @change="fnChangeChecked"
                    />
                    <el-button
                        type="text"
                        style="margin-left: 12px"
                        :disabled="multipleSelection.length === 0"
                        @click="handleDelete(multipleSelection)"
                    >批量移除</el-button>
                    <el-pagination
                        layout="total, prev, pager, next, jumper"
                        background
                        :current-page.sync="page.now_page"
                        :total="page.total_count"
                        :page-size="page.page_size"
                        @current-change="getTableData"
                    />
                </div>
            </div>
        </div>
        <!--图片预览-->
        <img-preview ref="preview"/>
        <!--商品选择弹窗-->
        <goods-select
            ref="goodsSelect"
            @change="handleSelectGoods($event)"
        />
    </section>
</template>

<script>
import { back } from '@/mixin/back';
import ImgPreview from "@/components/common/img-preview";
import GoodsSelect from "@/components/goods/goods-select";

export default {
    name: 'NoSettleGoodsList',
    mixins: [back],
    components: {GoodsSelect, ImgPreview},
    data() {
        return {
            filterData: {
                selectedType: [],
                goods_title: '',
                sort_field: '',
                sort_type: '',
            },
            typeList: [],
            tableData: [],
            tableLoading: false,
            page: {
                now_page: 1,
                total_count: 0,
                page_size: 20
            },
            checkedAll: false,
            checkIndeterminate: false,
            // 选中数据
            multipleSelection: [],
            authResult: {}
        };
    },
    computed: {},
    filters: {
        specFilter(val){
            if(!val){
                return '--';
            }
            let str = '';

            for(var i in val.spec_list){
                str += val.spec_list[i].spec_name + ':' + val.spec_list[i].spec_value;
                if(i < val.spec_list.length){
                    str += ',';
                }else{
                    str += ': ';
                }
            }

            if(str){
                str += '佣金' + val.product_commission+'元';
            }
            return str;
        },
        commissionRateFilter(val){
            if(val <= 0){
                return '--';
            }
            return val*1 + '%';
        },
        setGoodsType (val) {
            if (val == 1) {
                return '自营';
            } else if (val == 2) {
                return '合作淘客';
            } else if (val == 3) {
                return '普通淘客';
            } else if (val == 4) {
                return '商圈商品';
            } else if (val == 10) {
                return '二手商品';
            }
        }
    },
    watch: {},
    mounted() {
        this.$store.commit('SET_HEADER', [{title: "APP后台"}, {title: '商城'},{title: '商品列表', path: '/student/goods-list'},{title: '无需结算商品列表'}]);
        this.authResult = this.$route.meta.authResult;
        this.getTableData();
        this.getTypeList();
    },

    methods: {

        /**
         * @description 获取商品分类列表
         */
        getTypeList() {
            this.$post('/student/shop_goods_type%5Cget_list_linkage', {}, resp => {
                if(resp.code === 1){
                    this.typeList = resp.data.list;
                }
            });
        },

        /**
         * @description 获取列表数据
         * @param page
         */
        getTableData(page) {
            this.tableLoading = true;
            let params = { ...this.filterData };

            params.type_no = params.selectedType.length ? params.selectedType[0] : '';
            params.sub_type_no = params.selectedType.length === 2 ? params.selectedType[1] : '';
            params.page_id = page || this.page.now_page;
            this.$post('/student/shop_goods_for_trial_stuagent%5Cget_list', params, res => {
                if (res.code === 1) {
                    this.tableData = res.data.list;
                    this.page = res.data.page;
                } else {
                    this.$notify({
                        title: '提示',
                        message: res.msg,
                        type: 'warning'
                    });
                }
                this.tableLoading = false;
            });
        },

        /**
         * 路由跳转
         * @param routeName
         * @param query
         */
        handleRoute(routeName, query) {
            this.$router.push({
                name: routeName,
                query
            });
        },

        /**
         * @description 过滤函数
         */
        emptyFormatter(row, column, val) {
            if (!val) return '--';
            return val;
        },

        /**
         * 自定义表格标题hover提示
         */
        renderHeader(h,title, content){
            return h('span', {}, [
                h('span', {style: 'font-weight: bold'}, title),
                h('el-popover', { props: { placement: 'top-start', width: '200', trigger: 'hover', content: content }}, [
                    h('i', { slot: 'reference', class:'el-icon-question', style: 'color:#666;margin-left: 6px'}, '')
                ])
            ]);
        },

        /**
         * 跳转商品详情页
         */
        fnGoShoplist (row) {
            if (row.goods_url !== '' && row.goods_type !== 1) {
                window.open(row.goods_url);
                return;
            }

            if(row.goods_url == '' && (row.goods_type !== 1 && row.goods_type !== 8)) {
                this.$message({
                    type: 'warning',
                    message: '链接不可以为空'
                });
                return;
            }

            if(row.goods_type == 1 || row.goods_type == 8) {
                const routeData = this.$router.resolve({
                    name: 'goodsDetail',
                    query: {
                        no: row.goods_no
                    }
                });

                window.open(routeData.href, '_blank');
            }
        },

        /**
         * @description 查看图片
         * @param   {String}    images    单图预览
         * @param   {Array}     images     多图预览
         */
        fnShowPreview(images) {
            if(images && Object.prototype.toString.call(images) == '[object String]') {
                this.$refs.preview.show([
                    images
                ]);
            } else if (images && Object.prototype.toString.call(images) == '[object Array]') {
                this.$refs.preview.show(images);
            } else {
                this.$notify({
                    title: '提示',
                    message: '图片类型错误',
                    type: 'warning',
                    duration: 2000
                });
            }
        },

        /**
         * 重置筛选条件
         */
        handleReset() {
            this.filterData = {
                selectedType: [],
                goods_title: ''
            };
            this.getTableData(1);
        },

        /**
         * 排序
         */
        handleSortChanged(data) {

            let sortTypeMap = {
                ascending: 'asc',
                descending: 'desc'
            };

            let sortFieldMap = {
                "goods_sale": 'sale',
                "goods_sale_base": 'sale_base',
                "goods_sort": 'sort',
                "tuan_num": "tuan_num",
                "tuan_price": "tuan_price",
                "goods_price_origin": "origin_price",
                "coupon_money": "coupon_money",
                "goods_freight": "freight",
                "goods_commission": "commission",
                "goods_price": "goods_price",
                "goods_price_pay": "goods_price_pay",
                "create_time": "create_time",
                "cate_type_goods_sort": "cate_type_goods_sort"
            };

            if (data.order) {
                this.filterData.sort_field = sortFieldMap[data.prop];
                this.filterData.sort_type = sortTypeMap[data.order];
            } else {
                this.filterData.sort_field = '';
                this.filterData.sort_type = '';
            }

            this.getTableData();
        },

        fnGetSpec(good){
            this.$post('/student/shop_goods%5Cget', {
                goods_no: good.goods_no
            }, resp => {
                if(resp.code == 1){
                    let spec = resp.data.goods_product_list;

                    this.$set(good, 'specList', spec);
                    console.log(good.specList);
                }else{
                    this.$message({
                        type: 'warning',
                        message: resp.msg
                    });
                }
            });
        },

        /**
         * 上架/下架
         */
        fnSetStatus (row) {
            this.$post('/student/shop_goods%5Cset_status',{
                goods_no: row.goods_no,
                status: row.goods_status == 1 ? 1 : -1
            },resp => {
                if (resp.code == 1) {
                    this.$message({
                        type: 'success',
                        message: '设置成功'
                    });
                } else if (resp.code == 0) {
                    this.$message({
                        type: 'warning',
                        message: resp.msg
                    });
                }
            });
        },

        /**
         * 勾选
         * @param selection
         */
        fnSelect(selection) {
            this.checkedAll = selection.length == this.tableData.length;

            // 改变全选checkbox 的显示状态
            this.checkIndeterminate = selection.length > 0 && selection.length < this.tableData.length;
        },
        fnSelectAllTop(selection) {
            this.checkedAll = selection.length > 0;

            // 改变全选checkbox 的显示状态
            this.checkIndeterminate = selection.length > 0 && selection.length < this.tableData.length;
        },
        fnChangeChecked() {
            if(this.checkedAll){
                this.toggleSelection(1);
            }else{
                this.toggleSelection();
            }
        },
        toggleSelection(rows) {
            if (rows) {
                this.$refs.goodsTable.toggleAllSelection();
            } else {
                this.$refs.goodsTable.clearSelection();
            }
        },
        handleSelectionChange(val) {
            this.multipleSelection = val;
        },

        /**
         * 选择商品
         * @param val
         */
        handleSelectGoods(val) {
            let goods_nos = val.map(item => {
                return item.goods_no;
            }).join();

            this.$post('/student/shop_goods_for_trial_stuagent%5Cset_goods', {
                goods_nos,
                type: 1
            }, res => {
                if (res.code === 1) {
                    this.$notify({
                        title: '提示',
                        message: '添加成功',
                        type: 'success'
                    });
                    this.getTableData(1);
                } else {
                    this.$notify({
                        title: '提示',
                        message: res.msg,
                        type: 'warning'
                    });
                }
            });
        },

        /**
         * 添加商品
         */
        handleAdd() {
            if(!this.authResult.auth_set) {
                this.$notify({
                    title: '提示',
                    message: '请联系管理员添加权限',
                    type: 'warning',
                    duration: 2000
                });
                return false;
            }
            this.$refs.goodsSelect.show(2);
        },

        /**
         * 移除
         * @param data
         */
        handleDelete(data) {
            if(!this.authResult.auth_set) {
                this.$notify({
                    title: '提示',
                    message: '请联系管理员添加权限',
                    type: 'warning',
                    duration: 2000
                });
                return false;
            }
            this.$zdConfirm('移除后，购买该商品产生的佣金将恢复需要7天的结算期', '移除提醒', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                let goods_nos = data.map(item => {
                    return item.goods_no;
                }).join();

                this.$post('/student/shop_goods_for_trial_stuagent%5Cset_goods', {
                    goods_nos,
                    type: 0
                }, res => {
                    if (res.code === 1) {
                        this.$notify({
                            title: '提示',
                            message: '删除成功',
                            type: 'success'
                        });
                        this.getTableData(1);
                    } else {
                        this.$notify({
                            title: '提示',
                            message: res.msg,
                            type: 'warning'
                        });
                    }
                });
            }).catch(() => {});
        }
    }
};
</script>

<style lang="less" scoped>
.wrapper {
    width: 100%;

    .content-wrapper {
        display: flex;
        height: calc(100% - 24px);
        flex-direction: column;
        position: relative;
        margin: 12px;
        background: #fff;
        box-sizing: border-box;

        /*header*/

        .header {
            height: 68px;
            padding: 24px;
            box-sizing: border-box;
            box-shadow: 0px -1px 0px 0px #F0F2F5;
            display: flex;
            align-items: center;
            justify-content: space-between;
            border-bottom: 1px solid #F0F2F5;

            .header-title {
                color: #333333;
                font-size: 20px;
                height: 20px;
                font-weight: 500;
                position: relative;
                margin: 24px 0 24px 12px;

                &::before {
                    content: '';
                    position: absolute;
                    left: -8px;
                    top: -1px;
                    width: 3px;
                    height: 20px;
                    background: #1890FF;
                }
            }
            .back {
                font-size: 14px;
                font-family: PingFangSC-Medium, PingFang SC;
                font-weight: 500;
                color: #333333;
                cursor: pointer;
            }
        }

        .tips-view {
            height: 44px;
            background: #FFF6D6;
            padding: 0 35px;
            display: flex;
            align-items: center;
            font-size: 12px;
            font-family: PingFangSC-Regular, PingFang SC;
            font-weight: 400;
            color: #896C43;
        }

        /*筛选*/

        .filter-view {
            box-sizing: border-box;
            display: flex;
            align-items: center;
            flex-wrap: wrap;
            padding: 0 32px;
            margin-top: 24px;
            margin-bottom: 12px;
            justify-content: space-between;
            .left {
                display: flex;
                align-items: center;
            }
            .right {
                margin-bottom: 12px;
            }

            .header-new-box {
                display: flex;
                align-items: center;
                font-family: PingFangSC-Regular, PingFang SC;
                font-weight: 400;
                color: #333333;
                white-space: nowrap;
                margin-right: 24px;
                margin-bottom: 12px;

                &-title {
                    margin-right: 16px;
                    white-space: nowrap;
                }
                .query-button  {
                    width: 84px;
                    height: 36px;
                    background: #FFFFFF;
                    border-radius: 4px;
                    border: 1px solid #1890FF;
                    font-size: 14px;
                    font-family: PingFangSC-Medium, PingFang SC;
                    font-weight: 500;
                    color: #1890FF;
                    margin-right: 12px;
                }
            }
        }

        // 表格
        .table-wrapper {
            padding: 0 24px;
            flex: 1;
            height: 0;
            overflow: hidden;
            .goods-info {
                display: flex;
                align-items: center;
                .goods-cover {
                    width: 86px;
                    height: 86px;
                    cursor: pointer;
                    margin-right: 16px;
                }
                .info {
                    display: flex;
                    flex-direction: column;
                    justify-content: space-between;
                    font-size: 12px;
                    font-family: PingFangSC-Regular, PingFang SC;
                    font-weight: 400;
                    color: #333333;
                    .goods-info__title {
                        font-size: 14px;
                        cursor: pointer;
                        color: #409EFF;
                        display: -webkit-box;
                        -webkit-box-orient: vertical;
                        overflow: hidden;
                        -webkit-line-clamp: 2;
                    }
                }
            }
        }
        .data-table {
            ::-webkit-scrollbar {
                width: 6px;
                height: 6px;
            }
            // 操作按钮
            .option-btn-group {
                .el-button {
                    margin-left: 0;
                    margin-right: 10px;
                }
            }
        }
        .task-review-status {
            .status {
                position: relative;
                display: inline-block;
                padding-left: 9px;
                &::before {
                    content: "";
                    position: absolute;
                    top: 50%;
                    left: 0;
                    transform: translate(0, -50%);
                    width: 6px;
                    height: 6px;
                    border-radius: 50%;
                }
                &.wait-submit,
                &.wait-audit {
                    &::before {
                        background-color: #f5a623;
                    }
                }
                &.deny {
                    &::before {
                        background-color: #ff0019;
                    }
                }
                &.completed {
                    &::before {
                        background-color: #00c800;
                    }
                }
            }
        }

        /* 分页 */
        .pagination-wrapper {
            padding: 12px 24px;
            .el-pagination {
                margin-top: 6px;
                float: right;
                padding: 0;
                background-color: transparent;
            }
        }
    }
    /deep/ .el-dialog__header {
        padding-top: 10px;
        box-shadow:0 1px 0 0 rgba(233,233,233,1);
        display: flex;
        align-items: center;
        background: #FAFAFA;
        border-radius: 4px 4px 0 0;
        .el-dialog__title {
            font-weight: 500;
            color: #333;
            font-size: 14px;
        }
        .el-icon-close:before {
            color: rgb(194,194,194);
            font-size: 17px;
            font-weight: bold;
        }
        .el-dialog__headerbtn {
            top: 14px;
        }
    }
    /deep/ .el-textarea__inner {
        resize: none;
    }
    /deep/ .el-table__fixed-right {
        right: 6px!important;
    }
}
</style>

